#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100005;

struct Node
{
    int d;
    int v;
    int a;
}car[N];

struct node
{
    int dir, sum;
}p[N];


bool flag[N];
int sp[N];
double V;
int T, L;
int n, m;
vector < int > v;

bool over_speed(int i, int j)
{
    int v = car[j].v;
    int a = car[j].a;
    int s = p[i].dir - car[j].d;
    if(s < 0 || s > L) return false;
    double v_l = sqrt(v * v + 2 * a * s);
    if(v_l - V > 1e-9) return true;
    return false;
}

bool cmp(node a, node b)
{
    return a.sum > b.sum;
}

signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    
    scanf("%lld", &T);
    for(int k = 1; k <= T; k++)
    {
        memset(sp, 0, sizeof sp);
        memset(flag, 0, sizeof flag);
        memset(p, 0, sizeof p);
        
        
        int sum = 0;
        scanf("%lld%lld%lld%lf", &n, &m, &L, &V);
        for(int i = 1; i <= n; i++) scanf("%lld%lld%lld", &car[i].d, &car[i].v, &car[i].a);
        
        for(int i = 1; i <= m; i++)
        {
            scanf("%lld", &p[i].dir);
            for(int j = 1; j <= n; j++)
                if(over_speed(i, j))
                {
                    sp[j]++;
                    p[i].sum++;
                }
        }
        for(int i = 1; i <= n; i++) if(sp[i]) sum++;
        int cnt = 0;
        sort(p + 1, p + 1 + m, cmp);
        for(int i = 1; i <= m; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                bool f = over_speed(i, j);
                if(!flag[j] && f) flag[j] = true;
                else if(flag[j] && f) p[i].sum--;
            }
            if(p[i].sum <= 0) cnt++;
        }
        
        printf("%lld %lld\n", sum, cnt);
    }
    return 0;
}
